package com.wancaijinfu.component;


import com.wancaijinfu.actitvity.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

public class MPhotoDialog extends Dialog {
	private TextView photo;
	private TextView picture;
	private TextView middleView;

	private String up;
	private String middle;
	private String down;

	private View.OnClickListener listener1;
	private View.OnClickListener listener2;
	private View.OnClickListener listener3;

	public MPhotoDialog(Context context) {
		super(context);
	}

	public MPhotoDialog(Context context, int theme) {
		super(context, R.style.photoDialog);
	}
	
	public MPhotoDialog(Context context, int theme, String up, String middle, String down) {
		this(context, R.style.photoDialog);
		this.up = up;
		this.middle = middle;
		this.down = down;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_picture);
		this.getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
		this.getWindow().setWindowAnimations(android.R.anim.fade_in);
		WindowManager.LayoutParams lp = this.getWindow().getAttributes();

		DisplayMetrics dm = new DisplayMetrics();
		getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
		int width = dm.widthPixels;
		lp.width = width;
		getWindow().setAttributes(lp);

		photo = (TextView) findViewById(R.id.shangchuan);
		picture = (TextView) findViewById(R.id.bendizhaopian);
		middleView = (TextView) findViewById(R.id.bendi);

		if (up != null) {
			photo.setText(up);
		}
		if (down != null) {
			picture.setText(down);
		}
		if (middle != null) {
			middleView.setVisibility(View.VISIBLE);
			middleView.setText(middle);
		}
		findViewById(R.id.pianzizhuizong_cancel).setOnClickListener(
				new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						dismiss();
					}
				});

	}

	public void setOnClickListener(View.OnClickListener listener1,
			View.OnClickListener listener2) {
		photo.setOnClickListener(listener1);
		picture.setOnClickListener(listener2);
	}

	public void setOnClickListener(View.OnClickListener listener1,
			View.OnClickListener listener2, View.OnClickListener listener3) {
		setOnClickListener(listener1, listener2);
		middleView.setOnClickListener(listener3);
	}
}
